<?php
/**
 * Created by PhpStorm.
 * User: Frings
 * Date: 2018/2/11
 * Time: 1:17
 */

use yii\helpers\Url;

$web = Url::base();
?>


<div class="form-horizontal" id="data_form">
    <input type="hidden" id="id" name="id" class="form-control"
           value="<?= isset($item['id']) != null ? $item['id'] : '' ?>">

    <div class="form-group">
        <label class="control-label col-lg-2" for="code"><span
                class="font-color-attention">*</span>订单编号：</label>
        <div class="col-lg-10">
            <input type="text" id="name" name="name" class="form-control" disabled="disabled"
                   value="<?= $item != null ? $item['code'] : '' ?>">
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-lg-2" for="$total_selling_price"><span
                class="font-color-attention">*</span>订单总金额：</label>
        <div class="col-lg-10">
            <input type="text" id="raw_id" name="raw_id" class="form-control" disabled="disabled"
                   value="<?= $item != null ? $item['total_selling_price'] : '' ?>">
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-lg-2" for="app_id"><span
                class="font-color-attention">*</span>所属商城：</label>
        <div class="col-lg-10">
            <input type="text" id="app_id" name="app_id" class="form-control" disabled="disabled"
                   value="<?= $item != null ? \app\models\db\EShop::findOne($item['e_shop_id'])['name'] : '' ?>">
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-lg-2" for="app_secret"><span
                class="font-color-attention">*</span>下单用户：</label>
        <div class="col-lg-10">
            <input type="text" id="app_secret" name="app_secret" class="form-control" disabled="disabled"
                   value="<?= $item != null ? \app\models\db\TUser::findOne($item['user_id'])['name'] : '' ?>">
        </div>
    </div>


    <div class="form-group">
        <label class="control-label col-lg-2" for="type"><span
                class="font-color-attention">*</span>订单状态：</label>
        <div class="col-lg-4">
<!--            <select class='select-group' id="type" name="type"  disabled="disabled">-->
<!--                <option value="1" --><?php //echo $item['status'] == '1' ? 'selected' : '' ?><!-->支付宝小程序</option>-->
<!--                <option value="2" --><?php //echo $item['status'] == '2' ? 'selected' : '' ?><!-->微信小程序</option>-->
<!--            </select>-->
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-lg-2" for="remark"><span
                    class="font-color-attention">*</span>下单备注：</label>
        <div class="col-lg-10">
            <input type="text" id="remark" name="remark" class="form-control" disabled="disabled"
                   value="<?= $item != null ? $item['remark'] : '' ?>">
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-lg-2" for="create_datetime"><span
                    class="font-color-attention">*</span>下单时间：</label>
        <div class="col-lg-10">
            <input type="text" id="create_datetime" name="create_datetime" class="form-control" disabled="disabled"
                   value="<?= $item != null ?  \app\librarys\Tools::getDatetimeFormat($item['create_datetime'], 'Y-m-d H:m:s') : '' ?>">
        </div>
    </div>

    <div class="form-group">
        <div class="panel panel-frame">
            <div class="table-responsive">
                <table class="table table-bordered table-hover">
                    <thead>
                    <tr>
                        <th>商品编号</th>
                        <th>商品名称</th>
                        <th>销售单价</th>
                        <th>购买数量</th>
                        <th>总金额</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php
                    $goods = \app\models\db\OrderGoods::findAll(['order_id'=>$item['id']]);
                    for ($i = 0; $i < count($goods); $i++) {
                        $go = \app\models\db\Goods::findOne($goods[$i]->goods_id);
//                        $go = $goods[$i];
                        ?>
                        <tr>
                            <td><?= $go['code'] ?></td>
                            <td><?= $go['name'] ?></td>
                            <td><?= $go['selling_price'] ?></td>
                            <td><?= $goods[$i]['quantity'] ?></td>


                            <td><?= $go['selling_price']*$goods[$i]['quantity'] ?></td>

                        </tr>
                        <?php
                    }
                    ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>



    <div class="form-group">
        <div class="panel panel-frame">
            <div class="table-responsive">
                <table class="table table-bordered table-hover">
                    <thead>
                    <tr>
                        <th>收货人</th>
                        <th>收货人电话</th>
                        <th>收货地址</th>
                        <th>收货备注</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>

                        <tr>
                            <td><?= $item['receiver_name']?></td>
                            <td><?= $item['receiver_phone'] ?></td>
                            <td><?= $item['receiver_province'] ?><?= $item['receiver_city'] ?><?= $item['receiver_region'] ?><?= $item['receiver_address'] ?></td>
                            <td><?= $item['receiver_remark'] ?></td>
                            <td><a class="btn btn-link" href="javascript:showExpress('<?= $item['id'] ?>')">快递信息</a></td>
                        </tr>

                        <tr hidden="hidden" id="sendExpressView">
                            <td></td>
                            <td></td>
                            <td>
                                <textarea id="express_nos" rows="3" name="express_nos" maxlength="200" placeholder="请填写快递单号,多个快递单请换行" ><?php
                                    foreach ($expresses as $express){
                                        echo $express->express_no."\n";
                                    }

                                    ?>
                                </textarea>
                            </td>
                            <td>
                                <a class="btn btn-link" href="javascript:sendExpress('<?= $item['id'] ?>')"><?php
                                     if(empty($expresses))
                                         echo '添加快递单';
                                     else
                                         echo '修改快递单';
                                    ?></a>
                            </td>
                            <td></td>
                        </tr>

                    </tbody>

                </table>

                </div>

        </div>

    </div>



    <div class="panel panel-frame">
        <div class="table-responsive">
            <table class="table table-bordered table-hover">
                <thead>
                <tr>
                    <th>快递单号</th>
                    <th>快递公司</th>
                    <th>物流信息</th>
                </tr>
                </thead>
                <tbody>

                    <?php
                       foreach ($expresses as $express){
                           ?><tr><td><?=$express->express_no?></td>
                           <td><?=$express->express_comanpy?></td>
                           <td></td></tr><?php
                       }
                    ?>


                </tbody>

            </table>

        </div>

    </div>

</div>


<script type="text/javascript">
    $('.form_date').datetimepicker({
        language: 'zh-CN',
        weekStart: 1,
        todayBtn: 1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        minView: 2,
        forceParse: 0
    });
</script>